/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tests.domainModel;

import java.util.concurrent.ConcurrentHashMap;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import domainModel.Forum;
import domainModel.Member;
import domainModel.MemberInt;
import domainModel.Topic;
import domainModel.TopicInt;

import static org.junit.Assert.*;

/**
 *
 * @author iziko
 */
public class ForumTest {

    Member mem;
    Forum instance ;
    
    public ForumTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
        mem = new Member(1,"iziko","iz@mail","izik","orgad");
        instance = new Forum("forumTest1",mem);
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of addTopic method, of class Forum.
     */
    @Test
    public void testAddTopic() {
        System.out.println("addTopic");
        TopicInt newTopic = new Topic("topicTest1",mem);
        instance.addTopic(newTopic);
        assertTrue(instance.getTopics().contains(newTopic));
        //fail("The test case is a prototype.");
    }

    /**
     * Test of getId method, of class Forum.
     */
    @Test
    public void testGetId() {
        System.out.println("getId");
        int expResult = 1;
        int result = instance.getId();
        assertEquals(expResult, result);
    }

    /**
     * Test of getName method, of class Forum.
     */
    @Test
    public void testGetName() {
        System.out.println("getName");
        String expResult = "forumTest1";
        String result = instance.getName();
        assertEquals(expResult, result);
    }

    /**
     * Test of removeTopic method, of class Forum.
     */
    @Test
    public void testRemoveTopic() {
        System.out.println("removeTopic");
        int topicId = 0;
        instance.removeTopic(topicId);
        assertFalse(this.instance.getTopics().size() > 0);

    }

    /**
     * Test of setName method, of class Forum.
     */
    @Test
    public void testSetName() {
        System.out.println("setName");
        String name = "forumTest2";
        instance.setName(name);
       assertEquals(instance.getName(),name);
    }

    /**
     * Test of getCreator method, of class Forum.
     */
    @Test
    public void testGetCreator() {
        System.out.println("getCreator");
        MemberInt result = instance.getCreator();
        assertEquals(mem, result);
    }

    /**
     * Test of setCreator method, of class Forum.
     */
    @Test
    public void testSetCreator() {
        System.out.println("setCreator");
        MemberInt member = new Member(2,"iziko2","iz@mail","izik","orgad");
        instance.setCreator(member);
        assertEquals(member, instance.getCreator());
    }

    /**
     * Test of getTopics method, of class Forum.
     */
    @Test
    public void testGetTopics() {
        System.out.println("getTopics");
        ConcurrentHashMap expResult = new ConcurrentHashMap<Integer, TopicInt>();
        ConcurrentHashMap result = instance.getTopics();
        assertEquals(expResult, result);
    }

}